<?php
require_once 'ctlAbstract.php';

require_once $ubi['SERVER']['SERVER_ROOT'] . '/model/quick_message.php';

require_once $ubi['SERVER']['SERVER_ROOT'] . '/business/busQuick_Message.php';
require_once $ubi['SERVER']['SERVER_ROOT'] . '/business/busFriend.php';
require_once $ubi['SERVER']['SERVER_ROOT'] . '/business/busUser.php';

class RemoveController extends AbstractController {
	private $_quickMessageBus;
	private $_friendBus;
	private $_userBus;
	
	public function main(array $getVars) {
		global $ubi;
		
		$this->_quickMessageBus = new Quick_MessageBus();
		$this->_friendBus = new FriendBus();
		$this->_userBus = new UserBus();
		
		$userID = $_SESSION['userid'];
		
		if ($getVars['type'] == 'quick_message') {
			if ($userID != null) {	
				$receiverID = $_POST['reId'];
				if ($userID == $receiverID && isset($_POST['id'])) {					
					echo $this->_quickMessageBus->removeQuickMessage($getVars['id']);										
				}
			}		
		} else if ($getVars['type'] == 'friend') {
			if ($userID != null) {
				$friendID = $getVars['friendId'];
				echo $this->_friendBus->removeFriend($userID, $friendID);
			}
		} else if ($getVars['type'] == 'coupleInvitation') {
			$userID = $getVars['userid'];
			$receiverID = $getVars['receiverid'];
			$deleteCode = $getVars['deleteCode'];
			if (isset($userID) && isset($receiverID) && isset($deleteCode)) {
				$this->_userBus->removeCoupleInvitation($userID, $receiverID, $deleteCode);
				
				$notice = "RemoveMariageStatusSuccessfully";
				require_once $ubi['SERVER']['SERVER_ROOT'] .  '/view/viewNotice.php';
			}
		}		 
	}
}
?>